<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>导入车辆数据</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layuiadmin/style/admin.css" media="all">

    <style>

        #demo1 {
            display: block;
            width: 102px;
            height: 102px;
        }

    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">导入车辆数据 <span style="color: red">仅可导入.xlsx或者.xls后缀的文件</span> </div>
                <div class="layui-card-body" pad15>

                    <form class="layui-form" lay-filter="addForm" id="addForm">
<%--                            <input hidden id="userId" name="id" value="${applicationScope.user.id}">--%>
<%--                        <div class="layui-form-item" id="occupationType">--%>
<%--                            <label class="layui-form-label">当前职位</label>--%>
<%--                            <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->--%>
<%--                                <input type="text" value="${applicationScope.user.occupationType}"--%>
<%--                                       class="layui-input" readonly>--%>

<%--                                <div class="layui-form-mid layui-word-aux">职位不可修改</div>--%>
<%--                            </div>--%>
<%--                        </div>--%>
<%--                        <div class="layui-form-item">--%>
<%--                            <label class="layui-form-label">昵称</label>--%>
<%--                            <div class="layui-input-inline">--%>
<%--                                <input type="text" name="userNickname" id="addUserNickname" required--%>
<%--                                       value="${applicationScope.user.userNickname}"--%>
<%--                                       lay-verify="required"--%>
<%--                                       placeholder="请输入昵称"--%>
<%--                                       autocomplete="off" class="layui-input">--%>
<%--                            </div>--%>
<%--                        </div>--%>
<%--                        <div class="layui-form-item">--%>
<%--                            <label class="layui-form-label">电话</label>--%>
<%--                            <div class="layui-input-inline">--%>
<%--                                <input type="text" name="userPhone" id="addUserPhone"--%>
<%--                                       value="${applicationScope.user.userPhone}" required lay-verify="required"--%>
<%--                                       placeholder="请输入密码"--%>
<%--                                       autocomplete="off" class="layui-input">--%>
<%--                            </div>--%>
<%--                        </div>--%>
<%--                        <div class="layui-form-item" id="birthday">--%>
<%--                            <label class="layui-form-label">出生日期</label>--%>
<%--                            <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->--%>
<%--                                <input type="text" class="layui-input" id="addBirthday"--%>
<%--                                       value="<fmt:formatDate value='${applicationScope.user.birthday}' pattern='yyyy-MM-dd'/>" lay-verify="required"--%>
<%--                                       autocomplete="off" readonly>--%>
<%--                                <div class="layui-form-mid layui-word-aux">出生日期不可修改</div>--%>
<%--                            </div>--%>
<%--                        </div>--%>

<%--                        <input type="text" id="imgPath" name="imgPath" hidden>--%>

                        <%--头像上传--%>
                        <div class="layui-form-item" style="margin-left: 110px">
                            <div class="layui-inline">
                                <%--                    <div class="layui-upload">--%>
                                <button type="button" class="layui-btn" id="uploadImg">上传文件</button>
                                <%--                    </div>--%>
                            </div>
                        </div>
<%--                        <div class="layui-upload-list" style="margin-left: 110px">--%>
<%--                            <img class="layui-upload-img" id="demo1" src="${applicationScope.user.imgPath}">--%>
<%--                            <p id="demoText"></p>--%>
<%--                        </div>--%>


                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" type="button" lay-submit lay-filter="uploadVehicleRefuelingInfo"
                                        id="uploadVehicleRefuelingInfo">提交
                                </button>
                                <%--                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>--%>
                                <%--                                <button type="button" class="layui-btn layui-btn-primary" id="addReturnWindows">返回</button>--%>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${pageContext.request.contextPath}/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form', 'layer', 'laydate', 'upload'], function () {
        var table = layui.table,
            form = layui.form,
            layer = layui.layer,
            $ = layui.$,
            admin = layui.admin,
            laydate = layui.laydate
            , upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#uploadImg'
            , url: '${pageContext.request.contextPath}/vehicleRefuelingInfo/upload' //改成您自己的上传接口
            , accept: 'file'
            , auto: false
            , bindAction: '#uploadVehicleRefuelingInfo'
            , exts: 'xlsx|xls'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                if (res.code > 0) {
                    return layer.msg('上传失败');
                } else {
                    return layer.msg('上传成功');
                }
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });

    })
</script>
</body>
</html>